package com.example.demo;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

/*主启动类的自动扫描  <context:scan >
@SpringBootApplication:
* 1、@ComponentScan自动扫描包，主启动类不能放在根包
* 2、@SpringBootConfiguration:springboot配置类，结合@Configuration配置
* 3、@EnableAutoConfiguration:开启自动扫描配置包，通过AutoConfigurationImportSelector类实现自动配置类
* */
@SpringBootApplication
public class DemoApplication {

    /*
     * SpringApplication：spring应用程序启动类
     * 1、初始化SpringApplication对象
     * 2、this.webApplicationType = WebApplicationType.deduceFromClasspath();
     *    判断项目类型
     * 3、this.bootstrapRegistryInitializers = new ArrayList(this.getSpringFactoriesInstances(BootstrapRegistryInitializer.class));
     *    扫描类路径下META-INF/spring.factories配置文件，将配置文件中定义的自动配置类加载到内存中
     * 4、this.setInitializers(this.getSpringFactoriesInstances(ApplicationContextInitializer.class));
     *    根据上一步配置加载信息，初始化自动配置对象放入到initializers属性中
     * 5、this.setListeners(this.getSpringFactoriesInstances(ApplicationListener.
     *    应用程序所有监听器放入到listeners
     * 6、this.mainApplicationClass = this.deduceMainApplicationClass();
     *    找到设置的main方法所在的主启动类，运行此类
     * */

    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }

}
